package leetcode;


/**
 * Created by Ghost on 2014/11/7 0007.
 */
public class Set_Matrix_Zeroes {
    public void setZeroes(int[][] matrix) {
        int[] a = new int[matrix[0].length];
        int[] b = new int[matrix.length];
        for(int i=0;i<matrix.length;i++){
            for(int j=0;j<matrix[0].length;j++){
                if(matrix[i][j]==0){
                    b[i]=1;
                    a[j]=1;
                }
            }
        }


        for(int i=0;i<matrix.length;i++){
            if(b[i]==1)
                for(int j=0;j<matrix[0].length;j++)
                    matrix[i][j]=0;

        }

        for(int i=0;i<a.length;i++){
            if(a[i]==1)
                for(int j=0;j<matrix.length;j++)
                    matrix[j][i]=0;
        }
    }
    public static void main(String[] args){
        Set_Matrix_Zeroes set_matrix_zeroes = new Set_Matrix_Zeroes();
        int[][] matrix = {{1,1,1},{0,1,2}};
        set_matrix_zeroes.setZeroes(matrix);
    }
}
